<template>
  <default-home-card icon="ProfileTwoTone" title="房产项目统计">
    <div class="echarts-box">
      <div class="category-main" id="category-main-report-hp"></div>
    </div>
  </default-home-card>
</template>
<script setup lang="ts">
  import DefaultHomeCard from '/@/views/system/home/default-home-card.vue';
  import { reportApi } from '/@/api/task/report-api';
  import * as echarts from 'echarts';
  import { onMounted } from 'vue';

  onMounted(() => {
    init();
  });

  async function init() {
    let res=await reportApi.getRec3ProjectReport("17DD7B09E2CB4BE587DEF7ABD6F30830");
    let option = {
      xAxis: {
        type: 'category',
        data: res.data.xdata,
      },
      yAxis: {
        type: 'value',
      },
      legend: {},
      grid: {
        left: '3%',
        right: '4%',
        bottom: '3%',
        containLabel: true,
      },
      tooltip: {
        trigger: 'axis',
        axisPointer: {
          type: 'shadow',
        },
      },
      series: res.data.seriesData,
    };

    let chartDom = document.getElementById('category-main-report-hp');
    if (chartDom) {
      let myChart = echarts.init(chartDom);
      option && myChart.setOption(option);
    }
  }
</script>
<style lang="less" scoped>
  .echarts-box {
    display: flex;
    align-items: center;
    justify-content: center;
    .category-main {
      width: 100%;
      height: 280px;
      background: #fff;
    }
  }
</style>
